package com.jingdianjichi.subject.application.controller;

import com.jingdianjichi.subject.common.entity.Result;
import org.apache.ibatis.annotations.Param;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 测试mq的集成发送
 */
@RestController
@RequestMapping("/test/mq")
public class TestMqController {

    //mq客户端
    @Resource
    private RocketMQTemplate rocketMQTemplate;

    //发送消息到mq中
    @PostMapping("/pushMessage")
    public Result<Boolean> pushMessage(@Param("id") int id){
        //发送消息 //表示该消息将被发送到名为 "first-topic" 的主题中
        rocketMQTemplate.convertAndSend("first-topic","鸡翅早上好"+id);

        return Result.ok(true);
    }


}
